layui.use(['form','layer','layedit','laydate','upload'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        laypage = layui.laypage,
        upload = layui.upload,
        layedit = layui.layedit,
        laydate = layui.laydate,
        $ = layui.jquery;
    
    $(function () {

    form.verify({
        passwordNew : function(val){
            if(val == ''){
                return "新密码不能为空";
            }
        },
        passwordSec:function(val){
        	if(val == ''){
        		return "确认密码不能为空";
        	}else if(val != $(".passwordNew").val()){
        		return "两次输入密码不一样";
        	}
        }
        
    })
    
    form.on("submit(save)",function(data){
        //截取文章内容中的一部分文字放入文章摘要
       // var abstract = layedit.getText(editIndex).substring(0,50);
        //弹出loading
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        // 实际使用时的提交信息
        var passwordNew = $(".passwordNew").val();

        axios.put("/personal_blog/bloggers/passwordUpdate",{password:passwordNew}).then(function(response){
            setTimeout(function(){
                top.layer.close(index);
                top.layer.msg("个人信息更新成功！");
                layer.closeAll("iframe");
                //刷新父页面
                parent.location.reload();
            },500);

        })
        return false;
    })

    //预览
    form.on("submit(cencel)",function(){
        layer.confirm('确定退出编辑页面吗？', {icon: 3, title: '提示信息'}, function (index) {
        	 top.layer.close(index);
             //刷新父页面
             parent.location.reload();
        })
        
        return false;
    })

    })
})